package cn.taofuxn.sale.service.data.base;

/**
 * ProjectName : GeekSaleSystem
 * PackageName : cn.taofuxn.sale.service.data.base
 * Created by Wong
 * Date: 2018/3/16
 * Time: 11:18
 */
public class BaseResult {
	
	private int code;
	private String msg;
	private Object obj;
	
	public static BaseResult success() {
		return success(true);
	}
	
	public static BaseResult error() {
		return error(false);
	}
	
	public static BaseResult success(Object object) {
		BaseResult tBaseResult = generate(ResultCodeType.SUCCESS);
		tBaseResult.setObj(object);
		return tBaseResult;
	}
	
	public static BaseResult error(Object object) {
		BaseResult tBaseResult = generate(ResultCodeType.ERROR);
		tBaseResult.setObj(object);
		return tBaseResult;
	}
	
	public static BaseResult generate(ResultCodeType vCodeType) {
		BaseResult tBaseResult = new BaseResult();
		tBaseResult.setCode(vCodeType.getCode());
		tBaseResult.setMsg(vCodeType.getMsg());
		return tBaseResult;
	}
	
	public int getCode() {
		return code;
	}
	
	public void setCode(final int vCode) {
		code = vCode;
	}
	
	public String getMsg() {
		return msg;
	}
	
	public void setMsg(final String vMsg) {
		msg = vMsg;
	}
	
	public Object getObj() {
		return obj;
	}
	
	public void setObj(final Object vObj) {
		obj = vObj;
	}
	
	@Override
	public String toString() {
		return "BaseResult{" + "code=" + code + ", msg='" + msg + '\'' + ", obj=" + obj + '}';
	}
}
